<template>
  <div class="appraise-cell">
    <div class="img-container">
      <img v-lazy="appraiseItem.images">
    </div>
    <div class="title-container">
      <p>{{ appraiseItem.names }}</p>
      <input type="button" v-bind:value="!this.$props.appraiseItem.isAppraises ? '评价晒图' : '查看评价'"
             v-bind:style="{backgroundImage: getBtnBgUrl}"
             @click="appraiseClick(appraiseItem)">
    </div>
  </div>
</template>

<script>
  export default {
    name: 'appraise_cell',
    props: {
      appraiseItem: {}
    },
    computed: {
      getBtnBgUrl() {
        if (!this.$props.appraiseItem.isAppraises) {
          return 'url(' + require('../../assets/img/appraise/appraise_add_icon.png') + ')'
        }
        else {
          return 'url(' + require('../../assets/img/appraise/appraise_search_icon.png') + ')'
        }
      }
    },
    methods: {
      appraiseClick (appraiseItem) {
        console.log('评价列表跳转')
        console.log(appraiseItem)
        if (!this.$props.appraiseItem.isAppraises) {
          this.$emit('appraise-click', appraiseItem)
        } else {
          this.$router.push({
            path: '/commentList',
            query: {
              itemId: appraiseItem.goodsId
            }
          })
        }
      }
    }
  }
</script>

<style lang="scss">
  div.appraise-cell {
    box-sizing: border-box;
    padding: 10px 15px;
    width: 100%;
    height: 100%;

    >div.img-container {
      box-sizing: border-box;
      border: 1px solid rgb(233, 233, 233);
      position: relative;
      float: left;
      background-color: white;
      /*left: 15px;*/
      /*top: 10px;*/
      width: 30%;
      height: 100%;

      >img {
        /*width: 100px;*/
        height: 78px;
        max-width: 100px;
      }
    }

    >div.title-container {
      float: left;
      position: relative;
      width: 70%;
      height: 100%;
      /*background-color: red;*/

      >p {
        color: rgb(66, 66, 66);
        font-size: 14px;
        text-align: left;
        margin-left: 10px;
      }

      >input {
        /*display: inline-block;*/
        position: absolute;
        right: 0;
        bottom: 0;
        /*margin-right: 0;*/
        /*margin-bottom: 0;*/
        /*top: 50px;*/
        padding: 0 10px 0 10px;
        border: 1px solid rgb(27, 162, 232);
        color: rgb(27, 162, 232);
        background-color: white;
        border-radius: 5px;
        height: 30px;
        width: 100px;
        font-size: 14px;
        -webkit-appearance: none;
        outline: none;
        /*background-image: url("../../assets/img/appraise/appraise_add_icon.png");*/
        background-repeat: no-repeat;
        background-size:20px 20px;
        background-position:left;
        background-origin: content-box;
        text-align: right;
      }
    }
  }
</style>
